<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>自定义过滤器之手机加星过滤</title>
		<script src="../org/angular.min.js" ></script>
	</head>
	<body>
		<div ng-app = "hd" ng-controller = "ctrl">
			<table border="1" width="660px">
				<tr>
					<td>编号</td>
					<td>年龄</td>
					<td>手机号</td>
				</tr>
				<tr ng-repeat='v in data'>
					<td>{{v.id}}</td>
					<td>{{v.age}}</td>
					<td>{{v.tel|trancate:4}}</td>
				</tr>
			</table>
		</div> 
		<script>
			var m = angular.module('hd',[]);
			m.filter('trancate',function(){
				 return function(tel,len){
				 	return tel = tel.substr(0,11-len) + new String("*").repeat(len);
				 }
			})
			m.controller('ctrl',['$scope',function($scope){
				$scope.data = [{id:1,age:100,tel:"65564435677"},
				{id:2,age:200,tel:"45793754397"},
				{id:3,age:300,tel:"23567853568"}
				];
				
			}]);
		</script>
	</body>
</html>
